package com.bawei.fuxi.base.mvp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.bawei.fuxi.R;
import com.jaeger.library.StatusBarUtil;

public abstract class BaseActivity<V,P extends BasePresenter<V>> extends AppCompatActivity implements BaseView{
    protected P mPresenter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(bindLayout());
        //沉浸式状态栏
        StatusBarUtil.setTransparentForImageView(this,null);
        initView(savedInstanceState);
        mPresenter = createPresenter();
        initData();
        if(mPresenter != null){
            mPresenter.attach((V) this);
        }


    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(mPresenter != null){
            mPresenter.distach();
        }

    }

    public abstract int bindLayout();//返回布局id
    public abstract void initView(Bundle savedInstanceState);//初始化
    public abstract P createPresenter();//创建presenter
    public abstract void initData();//初始化
    @Override
    public void onOk() {

    }

    @Override
    public void onError() {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }
}